package com.fy.proj5_permission_transaction_cache.mapper;

import com.fy.proj5_permission_transaction_cache.model.RolePermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface RolePermissionMapper {
    // 根据角色ID查询角色权限关联
    List<RolePermission> findByRoleId(@Param("roleId") Long roleId);
    
    // 根据权限ID查询角色权限关联
    List<RolePermission> findByPermissionId(@Param("permissionId") Long permissionId);
    
    // 添加角色权限关联
    int insert(RolePermission rolePermission);
    
    // 批量添加角色权限关联
    int batchInsert(@Param("rolePermissions") List<RolePermission> rolePermissions);
    
    // 根据角色ID删除角色权限关联
    int deleteByRoleId(@Param("roleId") Long roleId);
    
    // 根据权限ID删除角色权限关联
    int deleteByPermissionId(@Param("permissionId") Long permissionId);
    
    // 删除指定的角色权限关联
    int deleteByRoleIdAndPermissionId(@Param("roleId") Long roleId, @Param("permissionId") Long permissionId);
}